MAKE = make
CPP = g++
AR = ar
LD = ld

NE_SDK = ../../../researchCenter/laboratory/nuclearengine

OPT =


INC = source
LIB = source
SRC = source
BIN = bin
PROJECT = PianoProgram

INCEX = -I$(INC) -I$(NE_SDK)/include -I$(NE_SDK)/include/third
LIBEX = -I$(LIB) -L$(NE_SDK)/lib
NESLIB = -lne

HEADS = $(SRC)/*.h \
        $(SRC)/Game/*.h

FILES = $(SRC)/*.cpp \
        $(SRC)/Game/*.cpp

OBJS = *.o

HOST_OS = $(shell uname)
ifeq ($(HOST_OS), Darwin)
	DEFINES = -DGLEW_NO_GLU -DNE_STATIC_LIB -DTIXML_USE_STL
	CPPFLAGS = -ggdb -c -O2 -arch x86_64 -m64 -m3dnow -fPIC -frtti -fexceptions -fcommon -Wall -isysroot $(MAC_OSX_SDK_PATH)
	LINKFLAGS = -O2 -arch x86_64 -fPIE -whatsloaded -isysroot $(MAC_OSX_SDK_PATH)
	# -fstats
	LIBS = -lGLEW -lfreetype -lfreeimage -lpthread -framework CoreFoundation -framework AGL -framework OpenGL -framework GLUT -framework CoreMIDI -framework AudioUnit -framework AudioToolbox
else
	EXE = .exe
	DEFINES = -DNE_STATIC_LIB -DTIXML_USE_STL
	CPPFLAGS = -c -O2 -frtti -fexceptions -mthreads -Wall
	LINKFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,console
	LIBS = -lopengl32 -lglut32 -lglew32 -lfreetype242 -lFreeImage -llibpng -lpthread -lwinmm
endif


all: target


target: $(FILES) $(HEADS)
	@echo '======== Compiling all [$(FILES)] ... ...'
	$(CPP) $(CPPFLAGS) $(DEFINES) $(INCEX) $(FILES)
	@echo '======== Linking [$(OBJS)] ... ...'
	$(CPP) $(LINKFLAGS) -o $(BIN)/$(PROJECT)$(OPT)$(EXE) $(OBJS) $(LIBEX) $(NESLIB) $(LIBS)
	@echo '======== Compiled all [$(FILES)] [Succeed]'
	@echo ''


clean: $(OBJS)
	@echo '======== Removing all [$(OBJS)] ... ...'
	rm $(OBJS)
	@echo '======== Removed all [$(OBJS)] Succeed'
